﻿using System;

namespace Borg.Framework
{
    public static class Binder
    {
        public static void BindAsPlugComboBoxTo(this System.Windows.Forms.ComboBox box, SlotInfo slot)
        {
            CheckSingleSelectionMode(slot);
            PlugComboBoxBinder.BindSlotToBox(slot, box);
        }

        public static void BindAsRegisterComboBoxTo(this System.Windows.Forms.ComboBox box, SlotInfo slot)
        {
            RegisterComboBoxBinder.BindSlotToBox(slot, box);
        }

        public static void BindAsSelectComboBoxTo(this System.Windows.Forms.ComboBox box, SlotInfo slot)
        {
            CheckSingleSelectionMode(slot);
            SelectComboBoxBinder.BindSlotToBox(slot, box);
        }

        private static void CheckSingleSelectionMode(SlotInfo slot)
        {
            if (slot.SelectionMode != SelectionMode.Single)
                throw new ArgumentException("the slot must be in SelectionMode.Single");
        }
    }
}

